/**
  ******************************************************************************
  * @file    gt32f030_lptim.c
  * @author  GT Application Team
  * @version V1.0.0
  * @date    03-January-2025
  *       
  ******************************************************************************
  * @attention
  *
  * <h2><center>&copy; COPYRIGHT 2022 Giantec Semicondutor Inc</center></h2>
  *
  *             http://www.giantec-semi.com/
  *
  * Unless required by applicable law or agreed to in writing, software 
  * distributed under the License is distributed on an "AS IS" BASIS, 
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  *
  ******************************************************************************
  */

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __GT32F030_LPTIM_H
#define __GT32F030_LPTIM_H

#ifdef __cplusplus
 extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "gt32f030.h"

/** @addtogroup GT32F030_StdPeriph_Driver
  * @{
  */

/** @addtogroup LPTIM
  * @{
  */ 

/* Exported macro ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/

/** @defgroup LPTIM_Exported_Constants
  * @{
  */ 
	 
/** @defgroup LPTIM_CLKSource 
  * @{
  */ 	 
typedef enum
{ 
  LPTIM_CLKSourceCmd_Disable    = 0x00,
  LPTIM_CLKSourceCmd_Enable     = 0x01
}LPTIMCLKSourceCmd_TypeDef;
#define IS_LPTIM_CLKSRCCMD(CMD) (((CMD) == LPTIM_CLKSourceCmd_Disable)     || \
                                 ((CMD) == LPTIM_CLKSourceCmd_Enable))

typedef enum
{ 
  LPTIM_CLKSource_PClk    = 0x00,
	LPTIM_CLKSource_LIRC    = 0x03
}LPTIMCLKSource_TypeDef;
#define IS_LPTIM_CLKSRC(CLKSRC) (((CLKSRC) == LPTIM_CLKSource_PClk)     || \
                                 ((CLKSRC) == LPTIM_CLKSource_LIRC))
/**
  * @}
  */ 


/** @defgroup LPTIM_function_configuration_define 
  * @{
  */ 
typedef enum
{ 
  LPTIM_GatePole_Low       = 0x00,
  LPTIM_GatePole_High      = 0x01
}LPTIMGatePole_TypeDef;
#define IS_LPTIM_GATEPOLE(POLE) (((POLE) == LPTIM_GatePole_Low)     || \
                                 ((POLE) == LPTIM_GatePole_High))

typedef enum
{ 
  LPTIM_FunctionMode_Timer       = 0x00,
  LPTIM_FunctionMode_Counter     = 0x01
}LPTIMFunctionMode_TypeDef;
#define IS_LPTIM_FUNCTIONMODE(FUNMODE) (((FUNMODE) == LPTIM_FunctionMode_Timer)     || \
                                        ((FUNMODE) == LPTIM_FunctionMode_Counter))

typedef enum
{ 
  LPTIM_LoadMode_FreeRun       = 0x00,
  LPTIM_LoadMode_AtuoReload    = 0x01
}LPTIMLoadMode_TypeDef;
#define IS_LPTIM_LOADMODE(LOADMODE) (((LOADMODE) == LPTIM_LoadMode_FreeRun)     || \
                                     ((LOADMODE) == LPTIM_LoadMode_AtuoReload))
/**
  * @}
  */

/**
  * @}
  */


/* Exported types ------------------------------------------------------------*/
/** 
  * @brief   LPTIM Init structure definition  
  */ 
typedef struct 
{
	LPTIMGatePole_TypeDef      LPTIM_GatePole;
	LPTIMFunctionMode_TypeDef  LPTIM_FunctionMode;
	LPTIMLoadMode_TypeDef      LPTIM_LoadMode;
	LPTIMCLKSource_TypeDef     LPTIM_CLKSource;
	LPTIMCLKSourceCmd_TypeDef  LPTIM_CLKSourceCmd;

	FunctionalState     LPTIM_ITCmd;
	FunctionalState     LPTIM_GateCmd;
	FunctionalState     LPTIM_ToggleCmd;	
  unsigned int            LPTIM_LoadVal; 
  unsigned int            LPTIM_BGLoadVal; 	                 
}LPTIM_InitTypeDef;


/* Exported functions --------------------------------------------------------*/
void LPTIM_DeInit(void);
void LPTIM_Init(LPTIM_InitTypeDef* BTIM_InitStruct);
void LPTIM_StructInit(LPTIM_InitTypeDef* LPTIM_InitStruct);

void LPTIM_Cmd(FunctionalState NewState);
void LPTIM_SetLoadVal(unsigned int LoadVal);
void LPTIM_SetBGLoadVal(unsigned int BGLoadVal);
unsigned int LPTIM_GetCountVal(void);

void LPTIM_ITConfig(FunctionalState NewState);
ITStatus LPTIM_GetIT(void);
void LPTIM_ClearIT(void);




#ifdef __cplusplus
}
#endif

#endif /* __GT32F030_CRC_H */

/**
  * @}
  */

/**
  * @}
  */

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
